#include "stdafx.h"
#include "INET_Addr.h"

INET_Addr::INET_Addr(u_short port, char* addr) 
{
	// Set up the address to become a server.
	memset(&addr_, 0, sizeof(addr_));		//Overwrites the address by 0.
	addr_.sin_family = AF_INET;				//Protocol.
	addr_.sin_port = htons(port);			//Converts the port number to big endian.
	if(addr == INADDR_ANY)
		addr_.sin_addr.s_addr = INADDR_ANY;
	else
		addr_.sin_addr.s_addr = inet_addr (addr);	//Converts the address to big endian.
}

u_short INET_Addr::get_port () const 
{ 
	return addr_.sin_port; 
}

u_long INET_Addr::get_ip_addr () const
{ 
	return addr_.sin_addr.s_addr; 
}

sockaddr* INET_Addr::addr() const
{ 
	return (sockaddr*)(&addr_);
}

size_t INET_Addr::size() const 
{ 
	return sizeof(addr_);
}

INET_Addr::~INET_Addr(void)
{

}